#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

string reverseOnlyLetters(string s)
{
	int pforward = 0;
	int preverse = s.size() - 1;
	while (pforward < preverse)
	{
		while ((!isalpha(s[pforward])) && (pforward < preverse))
		{
			++pforward;
		}
		while ((!isalpha(s[preverse])) && (pforward < preverse))
		{
			--preverse;
		}

		swap(s[pforward], s[preverse]);
		++pforward;
		--preverse;
	}

	return s;
}

int main()
{
	string s("ab-cd");
	cout << reverseOnlyLetters(s) << endl;

	return 0;
}